package com.zretc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zretc.dao.EmployeeSalaryMapper;
import com.zretc.entity.EmployeeSalary;
import com.zretc.service.EmployeeSalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class EmployeeSalaryServiceImpl  implements EmployeeSalaryService {
    @Autowired
    private EmployeeSalaryMapper employeeSalaryMapper;



    @Override
    public int updata(Integer employeeId, Integer salaryId) {
        return employeeSalaryMapper.update(employeeId,salaryId);
    }

    @Override
    public PageInfo<EmployeeSalary> find(Map<String, Object> map) {
        Integer page = (Integer) map.get("page");
        Integer size = (Integer) map.get("size");
        String name = (String) map.get("name");
        if (name==""){
            map.put("name",null);
        }
        PageHelper.startPage(page,size);
        List<EmployeeSalary> employeeSalaries = employeeSalaryMapper.find(map);
        PageInfo<EmployeeSalary> pageInfo=PageInfo.of(employeeSalaries);
        return pageInfo;
    }
}
